home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DJLSR106.ARJ / GETS.C < prev    next >
C/C++ Source or Header  |  1992-03-02  |  581b  |  28 lines

  1. /* This is file GETS.C */
  2. /* This file may have been modified by DJ Delorie (Jan 1991).  If so,
  3. ** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave,
  4. ** Rochester NH, 03867-2954, USA.
  5. */
  6.  
  7. #if defined(LIBC_SCCS) && !defined(lint)
  8. static char sccsid[] = "@(#)gets.c    5.2 (Berkeley) 3/9/86";
  9. #endif LIBC_SCCS and not lint
  10.  
  11. #include    <stdio.h>
  12.  
  13. char *
  14. gets(s)
  15. char *s;
  16. {
  17.     register c;
  18.     register char *cs;
  19.  
  20.     cs = s;
  21.     while ((c = getchar()) != '\n' && c != EOF)
  22.         *cs++ = c;
  23.     if (c == EOF && cs==s)
  24.         return(NULL);
  25.     *cs++ = '\0';
  26.     return(s);
  27. }
  28.